package com.es.text;

import com.es.pojo.Product;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author:左泽林
 * @date:日期:2021-08-30-时间:10:35
 * @message:
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringDataESIndexTest {

    @Autowired
    private ElasticsearchRestTemplate elasticsearchRestTemplate;


    @Test
    public void createIndex(){
        //创建索引，系统初始化会自动创建索引
        System.out.println("创建索引");
    }

    @Test
    public  void deleteIndex(){
        //创建索引，系统初始化会自动创建索引
        boolean b = elasticsearchRestTemplate.deleteIndex(Product.class);
        System.out.println("删除索引是否成功====>"+b);
    }

}

